<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8"%>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>     
    <title>社会保障卡个人换卡登记</title>    
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="${pageContext.request.contextPath }/scripts/boot.js"
	type="text/javascript"></script>
		<script src="${pageContext.request.contextPath }/scripts/readcard.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath }/scripts/LodopFuncs.js"
	type="text/javascript"></script>
<style type="text/css">
html,body {
	font-size: 12px;
	padding: 0;
	margin: 0;
	border: 0;
	height: 100%;
	overflow: hidden;
}
 
</style>
	

  </head>
  
  <body onload="makePC()">
  <fieldset style="border:solid 1px #aaa;padding:3px;">
  <legend >个人换卡登记</legend>
  <form id="form1"  method="post">
   <div style="padding-left:11px;padding-bottom:5px;text-align:center">
  <table width="100%" style="table-layout:fixed" >
    <tr>
      <td style="white-space:nowrap;width:90px;text-align:right" >社会保障卡号:</td>
      <td style="width:180px"><input name="aac001" class="mini-textbox" vtype="int;minLength:10" maxlength="10" onenter="onKeyEnter" required="true" style="width:100%" emptyText="请输入社会保障卡号"/></td>
      <td style="width:90px;text-align:right">制卡批次:</td>
      <td style="width:180px"><input name="aaz001" class="mini-textbox" style="width:100%" inputStyle="background:rgb(241,241,243)" allowInput="false"/></td>
       <td style="width:90px;text-align:right">姓名:</td>
      <td style="width:180px"><input name="aac003" class="mini-textbox" inputStyle="background:rgb(241,241,243)" inputStyle="background:#c0c0c0" style="width:100%" allowInput="false"/></td>
      <td style="width:180px" colspan="2" rowspan="5"><div id="pic" align="center" style="height:100%;background-color:rgb(241,241,243);">
      <img src="" id="img0" style="height:200px;width:150px"/></div></td>
    </tr>
     <tr>
      <td style="width:90px;text-align:right">姓名拼音码:</td>
      <td style="width:180px"><input name="aaz742" class="mini-textbox" maxlength="20" inputStyle="background:rgb(241,241,243)" readonly="readonly"    style="width:100%" allowInput="true"/></td>
      <td style="width:90px;text-align:right">性别:</td>
      <td style="width:180px"><input name="aac004" class="mini-combobox" inputStyle="background:rgb(241,241,243)" style="width:100%" allowInput="false"
      url="${pageContext.request.contextPath }/make.do?method=getaac004&lx=AAC004" valueField="aaa102" textField="aaa103" readonly="readonly"/> </td>          
      <td style="width:90px;text-align:right">出生年月:</td>
      <td style="width:180px"><input name="aac006" class="mini-datepicker"  valueType="String" inputStyle="background:rgb(241,241,243)" readonly="readonly" style="width:100%" allowInput="false"/></td>     
    </tr>
    <tr> 
    <td style="width:90px;text-align:right">民族:</td>
      <td style="width:180px"><input name="aac005" class="mini-combobox" inputStyle="background:rgb(241,241,243)" style="width:100%" allowInput="false"
      url="${pageContext.request.contextPath }/make.do?method=getaac005&lx=AAC005" valueField="aaa102" textField="aaa103" readonly="readonly"/></td>          
     <td style="width:90px;text-align:right">证件类型:</td>
      <td style="width:180px"><input name="aac058" class="mini-combobox" style="width:100%" inputStyle="background:rgb(241,241,243)"  allowInput="false" readonly="readonly"
       url="${pageContext.request.contextPath }/make.do?method=getaac058&lx=AAC058" textField="aaa103" valueField="aaa102" readonly="readonly"/></td>      
      <td style="width:90px;text-align:right">证件号:</td>
      <td style="width:180px"><input name="aac002" class="mini-textbox" style="width:100%" inputStyle="background:rgb(241,241,243)"  allowInput="false"/></td>
    </tr>  
    <tr>    
    <td style="width:90px;text-align:right">联系电话:</td>
      <td style="width:180px"><input name="aae005" class="mini-textbox" inputStyle="background:rgb(241,241,243)" allowInput="false" style="width:100%" /></td>     
    <td style="width:90px;text-align:right">银行:</td>
      <td style="width:180px"><input name="aae008" class="mini-combobox" required="true" style="width:100%"
      url="${pageContext.request.contextPath }/make.do?method=getyinhang&sj=bank" textField="aaa103" valueField="aaa102" emptyText="请选择..." /></td> 
      <td style="width:90px;text-align:right">免费证件号:</td>
      <td style="width:180px"><input name="aaz738" class="mini-textbox" maxlength="60"  emptyText="请输入免费证件号"  style="width:100%"/></td>                  
   
    </tr>
    <tr>  
      <td style="width:90px;text-align:right">发证机构:</td>
      <td style="width:480px" colspan="3"><input name="aaz768" class="mini-textbox" maxlength="64" required="true"  emptyText="请输入发证机构"  style="width:100%"/></td>              
      <td style="width:90px;text-align:right">联系地址邮编:</td>
      <td style="width:180px"><input name="aae007" class="mini-textbox" required="true" vtype="int;minLength:6" maxlength="6" emptyText="请输入联系地址邮编" style="width:100%" /></td>    
    </tr>
    <tr>
     <td style="width:90px;text-align:right">联系地址:</td>
      <td style="width:480px" colspan="3"><input name="aac046" class="mini-textbox" required="true" maxlength="100" emptyText="请输入联系地址" style="width:100%"/></td>  
    </tr>
  </table>
</div>
</form>
  <div style="text-align:center;padding:10px;">
				<a class="mini-button" onclick="onOk" iconCls="icon-ok" id="onoks" name="onoks"  enabled="false"
					style="width:60px;margin-right:20px;">确定</a> <a class="mini-button"
					iconCls="icon-remove" onclick="onReset" 
					style="width:60px;margin-right:20px;margin-right:20px;">重置</a>
					<a class="mini-button" id="print"
					iconCls="icon-print" enabled="false" onclick="Preview"  
					style="width:60px;margin-right:20px;">打印</a>
					
					<a class="mini-button" id="card" name="card" onclick="getsfz" enabled="true" iconCls="icon-goto" style="width:100px;margin-right:20px;">读身份证</a>
					
					</div>
</fieldset>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");
function onKeyEnter()
        {
          var aac001 = mini.getbyName("aac001").getValue().trim();  
          var aaz001 = mini.getbyName("aaz001").getValue().trim();  
           if(aac001 == "")
          {
             mini.alert("请输入社会保障卡号");
             return;
          } else{                          
           $.ajax({               
                    url: "/sbk/make.do?method=getgrunitdata2",
                    cache: false,
                    data:{id:aac001,aaz001:aaz001},
                    success: function (text) {    
                     if("null" == text || "" == text || null == text)
                        {
                          mini.alert("无效社保卡号");
                          return;
                        }                            
                        var o = mini.decode(text); 
                        if(o.msg == "0") {
                        mini.getbyName("aac004").setValue(o.aac004);                       
                        mini.getbyName("aac058").setValue(o.aac058);                      
                        mini.getbyName("aac005").setValue(o.aac005);                                        
                        mini.getbyName("aac003").setValue(o.aac003);                         
                        mini.getbyName("aac002").setValue(o.aac002);  
                        mini.getbyName("aae005").setValue(o.aae005);                     
                        mini.getbyName("aac006").setValue(o.aac006);
                        mini.getbyName("aaz742").setValue(o.aaz742);
                        $("#img0").attr("src", "${pageContext.request.contextPath}/Picture/"+aac001+".JPG") ;
                        mini.get("onoks").setEnabled(true); 
                        labelModel();    
                        }                                                                  
                        else  {                                                
                           mini.alert(o.msg);
                           return;
                        }                                                 
                    }
                });   
                }     
        }
 		function makePC() {               
         $.ajax({               
                    url: "/sbk/make.do?method=getgrMakePc",                                     
                    success: function (text) {                                                     
                    mini.getbyName("aaz001").setValue(text);                                                                                                                                        
                    }
                });    
        
        }
        
         function getsfz() {
    			
				var info=readsfz();
                var sfz=info["sfzhm"];
            	 $.ajax({               
                    url: "/sbk/zpcj.do?method=getCard",
                    cache: false,
                    data:{sfz:sfz},
                    success: function (text) { 
                    	if(0==text)
						{
							alert("该人员未建档,请先登记该人员基础信息");
						}
						else
						{	
							  mini.getbyName("aac001").setValue(text);
							  onKeyEnter();
						}
                    	
                    }
				    });        
    		}
        
          function onOk(e) {
        
           SaveData();
        }
        
        function SaveData() {
            var aac001 = mini.getbyName("aac001").getValue().trim(); 
			var o = form.getData();				
			form.validate();
			if (form.isValid() == false)
			return;
			if(form.isValid()==true){
      	  		mini.mask({el: document.body,cls: 'mini-mask-loading',html: '保存中...'});      	 	
			var json = mini.encode([o]);		
			$.ajax({
				url : "/sbk/make.do?method=savegrhkunit",
				type : 'post',
				data : {
					data : json,id:aac001
				},
				cache : false,
				success : function(text) {	
				    mini.unmask();				  				   			
					if("0"==text) {
					    mini.alert("登记成功");
					    labelModel1();
					    mini.get("print").setEnabled(true); 
		               	mini.get("onoks").setEnabled(false);   
				  	} else {
						mini.alert("登记失败:"+text);
						onReset();
					}					
				},
				error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText);					
				}
			});
		}	
		}
		 function labelModel() {
            var fields = form.getFields();                          
                var c = fields[0];
                if (c.setReadOnly) c.setReadOnly(true);     //只读
                if (c.setIsValid) c.setIsValid(true);      //去除错误提示
                if (c.addCls) c.addCls("asLabel");          //增加asLabel外观           
        }
        
         function labelModel1() {
            var fields = form.getFields();  
            for (var i = 10, l = fields.length; i < l; i++) {                        
                var c = fields[i];
                if (c.setReadOnly) c.setReadOnly(true);     //只读
                if (c.setIsValid) c.setIsValid(true);      //去除错误提示
                if (c.addCls) c.addCls("asLabel");   //增加asLabel外观       
               }             
        }
        
         function inputModel1() {
            var fields = form.getFields();
            for (var i = 10, l = fields.length; i < l; i++) {
                var c = fields[i];
                if (c.setReadOnly) c.setReadOnly(false);
                if (c.removeCls) c.removeCls("asLabel");
            }
            mini.repaint(document.body);
        }
        
         function inputModel2() {
            var fields = form.getFields();           
                var c = fields[0];
                if (c.setReadOnly) c.setReadOnly(false);
                if (c.removeCls) c.removeCls("asLabel");          
            mini.repaint(document.body);
        }
   function onReset(e) {
            inputModel1();
            inputModel2();
			form.clear();
			$("#img0").attr("src", "");
			mini.get("print").setEnabled(false); 
		    mini.get("onoks").setEnabled(false); 
			makePC();
		}
      var LODOP; //声明为全局变量 

	function Preview() {		
		CreatePrintPage();
	  	LODOP.PREVIEW();		
	};
	function CreatePrintPage() {
		LODOP=getLodop(); 
		var aac003=mini.getbyName("aac003").getValue().trim();  //姓名
		var aaz742=mini.getbyName("aaz742").getValue().trim();  //拼音
		var aac001=mini.getbyName("aac001").getValue().trim();  //社会保障号
		var aac058=mini.getbyName("aac058").getText().trim();  //证件类型
		var aaz768=mini.getbyName("aaz768").getValue().trim();  //发证机构
		var aac002=mini.getbyName("aac002").getValue().trim();  //证件号
		var aac004=mini.getbyName("aac004").getText().trim();  //性别
		var aac006=mini.getbyName("aac006").getValue().trim();  //出生年月
		var aac005=mini.getbyName("aac005").getText().trim();  //民族
		var aae005=mini.getbyName("aae005").getValue().trim();  //联系电话
		var aac046=mini.getbyName("aac046").getValue().trim();  //联系地址
		var aae007=mini.getbyName("aae007").getValue().trim();  //邮编 aaz001
		var aaz001=mini.getbyName("aaz001").getValue().trim();  //批次号
		var now=new Date(); //创建Date对象 
		var year=now.getFullYear(); //获取年份 
		var month=now.getMonth()+1; //获取月份 
		var date=now.getDate();   //获取日期
	    LODOP.PRINT_INITA(1,-1,808,1078,"");
		LODOP.ADD_PRINT_TEXT(117,263,100,22,aac003); //姓名
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(117,432,206,20,aaz742);   //拼音
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(157,230,100,20,aac058);   //证件类型
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(157,405,50,20,"南京");
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(157,528,155,20,aac002);   //证件号
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(204,195,35,20,aac004);     //性别
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(204,274,40,20,aac005);   //民族
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(244,393,291,20,aac046);   //联系地址
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(244,223,100,20,aae005);  //联系电话
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(204,380,200,20,aac006);  //出生年月
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(86,149,171,20,aac001);   //社会保障号
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
		LODOP.ADD_PRINT_TEXT(203,544,135,20,aae007);  //邮编
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(285,200,50,20,"");   //代理人
		LODOP.SET_PRINT_STYLEA(0,"FontSize",10);
		LODOP.ADD_PRINT_TEXT(285,363,55,20,"");   //代理人证件类型
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11); 
		LODOP.ADD_PRINT_TEXT(285,537,155,20,"");  //代理人证件号
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(341,158,155,20,aaz001);  //批次号
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(341,522,146,20,year+"-"+month+"-"+date);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(388,158,155,20,aaz768);  //发证机构
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(385,427,65,20,"");  //经办人 
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		LODOP.ADD_PRINT_TEXT(382,590,90,20,year+"-"+month+"-"+date);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
		};
   
</script>
  </body>
</html>
